import game
import pygame

ENEMY_CREATE_EVENT = pygame.USEREVENT

pygame.init()
screen = pygame.display.set_mode((1536, 864))
bg1 = game.bg("./source/bg.jpeg", (0, 0), 10)
bg2 = game.bg("./source/bg.jpeg", (1920, 0), 10)
p1 = game.player_1("./source/player.png",spawnpoint=(0, 400), speed=3)

gr = pygame.sprite.Group(bg1, bg2)
enemys = pygame.sprite.Group()
players = pygame.sprite.Group()
players.add(p1)

clo = pygame.time.Clock()
pygame.time.set_timer(ENEMY_CREATE_EVENT, 1000)


while True:
    clo.tick(60)
    # 屏幕走马灯效果
    bg1.update()
    bg2.update()

    # for event in pygame.event.get():
    #     if event.type == ENEMY_CREATE_EVENT:
    #         enemy = game.enemy("./source/ene.png")
    #         enemys.add(enemy)
    #         break

    # enemys.update()

    
    players.update()
    # players.update()

    gr.draw(screen)
    players.draw(screen)

    # enemys.draw(screen)
    
    pygame.display.update()
